/**
  *****************************************************************************
  *           Copyright(c) 2023 China Core Co. Ltd.
  *                    All Rights Reserved
  *****************************************************************************
  * @file    status.h
  * @author  Product application department
  * @version V1.0
  * @date    2023.10.26
  * @brief   Header file of HAL DEF.
  *
  ******************************************************************************
  */

#ifdef __cplusplus
extern "C"
{
#endif

    /* Define to prevent recursive inclusion -------------------------------------*/

#ifndef _STATUS_H_
#define _STATUS_H_

    /* Exported types ------------------------------------------------------------*/
    /**
  * @brief  HAL Status structures definition
  */
typedef enum
{
    STATUS_OK = 0x0000,
    STATUS_RESET = 0xE000,
    STATUS_READY = 0xE001,
    STATUS_ERROR = 0xE002,
    STATUS_BUSY = 0xE003,
    STATUS_TIMEOUT = 0xE004,
    STATUS_IDLE = 0xE005,
    STATUS_FULL = 0xE006,
    STATUS_HANDLE_ERR = 0xEE01,
    STATUS_TYPE_ERR = 0xEE02,
    STATUS_NUM_ERR = 0xEE03,
    STATUS_ADDR_ERR         = 0xEE03,

    //  /*CPM error code*/
    //  HAL_CPM_ERROR_SYSCLKDIV_OUTRANGE   = 0x100,  /*!< ϵͳʱ�ӷ�Ƶ error */

    //  /*DMA error code*/
    //  HAL_DMA_ERROR_TE                   = 0x110,  /*!< Transfer error    */
    //  HAL_DMA_ERROR_CHANNEL_OUTRANG      = 0x111,  /*!< DMAͨ���������������Χr    */
} Status_TypeDef;

/** 
 * @brief  HAL Lock structures definition  
 */
typedef enum
{
 UNLOCKED = 0x00,
 LOCKED = 0x01
} Lock_TypeDef;

    /**
  * @brief  HAL Status structures definition
  */

    /* Exported macro ------------------------------------------------------------*/

#define MAX_DELAY 0xFFFFFFFF

#if (USE_RTOS == 1)
#error " USE_RTOS should be 0 in the current HAL release "
#else
#define __LOCK(__HANDLE__)                  \
    do                                      \
    {                                       \
        if ((__HANDLE__)->lock == LOCKED) \
        {                                   \
            return STATUS_BUSY;             \
        }                                   \
        else                                \
        {                                   \
            (__HANDLE__)->lock = LOCKED;    \
        }                                   \
    } while (0)

#define __UNLOCK(__HANDLE__)           \
    do                                 \
    {                                  \
        (__HANDLE__)->lock = UNLOCKED; \
    } while (0)
#endif /* USE_RTOS */

#ifndef __GNUC__
#define __GNUC__
#endif

#if defined(__GNUC__)
#ifndef __weak
#define __weak __attribute__((weak))
#endif /* __weak */

#ifndef WEAK
#define WEAK __attribute__((weak)) /*!< Defines 'WEAK' permissions */
#endif                             /* WEAK */

#ifndef __packed
#define __packed __attribute__((__packed__))
#endif /* __packed */

#endif /* __GNUC__ */

#ifdef __cplusplus
}
#endif

#endif /* _STATUS_H_ */

/************************ (C) COPYRIGHT C*Core *****END OF FILE****/
